#ifndef TABLE_WINDOW_H
#define TABLE_WINDOW_H

#include "socket_helper.h"
#include "table_delegate.h"

#include <QHBoxLayout>
#include <QLineEdit>
#include <QListView>
#include <QPushButton>
#include <QStandardItemModel>
#include <QTextEdit>
#include <QWidget>
#include <QTimer>


class TableWindow :public QWidget,public TableHelper
{
    Q_OBJECT
    QString user_name_;
    QString url_;
public:
    TableWindow(QWidget *parent,const QString &user_name,const QString &url);
    ~TableWindow();
private:
    QHBoxLayout *info_container;
    QVBoxLayout *container;
    QListView *table;
    QTextEdit *label_chat;
    QPushButton *button_send;
    QPushButton *button_refresh;
    QHBoxLayout *layout_chat;
    QLineEdit *edit_input;
    QStandardItemModel *pModel;
    QString m_chat_content;
    QTimer *timer;
private :
    void on_table_item_clicked(const QModelIndex &index ,int position);
private:
    void init_connect();
public :
    void on_connected()  override;
    void on_message(const QByteArray &message) override;
    void on_message(const QString &message) override;
    void on_disconnect() override;
public:
    void on_send_clicked(bool);

    void on_table_response_error(const int &code,const int &rep_code,const QString &rep_message,const QString &tag)override;

    void on_chat_message(const ChatData &data)override;

    void on_server_info_message(const QVector<TableItem> &data)override;

    void on_person_changed_notify(const PersonNotifyhData &data)override;

    void closeEvent(QCloseEvent *event) override;

    void on_time_out();
};
#endif // TABLE_WINDOW_H
